<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>计算迭代器中元素的个数</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.iterator-count" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">iterator_count</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.1.0, PHP 7)</p><p class="refpurpose"><span class="refname">iterator_count</span> &mdash; <span class="dc-title">计算迭代器中元素的个数</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.iterator-count-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>iterator_count</strong></span>
    ( <span class="methodparam"><span class="type"><a href="class.traversable.html" class="type Traversable">Traversable</a></span> <code class="parameter">$iterator</code></span>
   ) : <span class="type">int</span></div>

  <p class="para rdfs-comment">
   计算迭代器中的元素个数。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.iterator-count-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">iterator</code></dt>

     <dd>

      <p class="para">
       要计数的迭代器。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.iterator-count-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   迭代器<code class="parameter">iterator</code>中的元素个数。
  </p>
 </div>



 <div class="refsect1 examples" id="refsect1-function.iterator-count-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="regexiterator.getflags.example.basic">
    <p><strong>Example #1 <span class="function"><strong>iterator_count()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$iterator&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">ArrayIterator</span><span style="color: #007700">(array(</span><span style="color: #DD0000">'recipe'</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">'pancakes'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'egg'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'milk'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'flour'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">iterator_count</span><span style="color: #007700">(</span><span style="color: #0000BB">$iterator</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
int(4)
</pre></div>
    </div>
   </div>
  </p>
 </div>


</div></div></div></body></html>